//
//  UIButton+Utils.m
//  lvgouProjectIphone
//
//  Created by 张明磊 on 14-3-26.
//  Copyright (c) 2014年 lvgou. All rights reserved.
//

#import "UIButton+Utils.h"
#import "UIImage+Utils.h"

@implementation UIButton (Utils)

#pragma mark - 设置压缩图片 -
/**
 *  设置压缩图片
 */
- (void)setImageScalingWithFileName:(NSString *)filename withState:(UIControlState)state
{
    @autoreleasepool
    {
        NSString *imageFile = [[NSString alloc]initWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], filename];
        UIImage *image =  [[UIImage alloc] initWithContentsOfFile:imageFile];
        UIImage *image_scaling;
        if([UIScreen mainScreen].currentMode.size.width == 320)
        {
            image_scaling = [image imageByScalingAndCroppingForSize:CGSizeMake(self.frame.size.width, self.frame.size.height)];
        }
        else
        {
            image_scaling = [image imageByScalingAndCroppingForSize:CGSizeMake(self.frame.size.width * 2, self.frame.size.height * 2)];
        }
        [self setImage:image_scaling forState:state];
        //[self setBackgroundImage:image_scaling forState:state];
    }
}


@end
